import {CFormGroupProps} from "@/components/CProForm/CFormItem/type";
import ReactQuill from "react-quill";
import {SelectProps} from "antd";
const fields = (newsCategoryList: SelectProps["options"],
                newsTagList: SelectProps["options"]):CFormGroupProps => [
  {
    itemList: [
      {
        name: "title",
        label: "标题",
        labelAlign: "right",
        rules: [
          {
            message: "标题是必填项",
            required: true
          }
        ],
        width: "md",
        placeholder: "请输入标题",
      }
    ]
  },
  {
    itemList: [
      {
        name: "categoryId",
        label: "分类",
        labelAlign: "right",
        type: "select",
        options: newsCategoryList,

        rules: [
          {
            message: "分类id是必填项",
            required: true
          }
        ],
        width: "md",
        placeholder: "请输入分类",
      }
    ]
  },
  {
    itemList: [
      {
        name: "tagIdList",
        label: "标签",
        labelAlign: "right",
        type: "select",
        options: newsTagList,
        componentProps: {
          allowClear: true,
          mode: "multiple",
        },
        rules: [
          {
            message: "分类是必填项",
            required: true
          }
        ],
        width: "md",
        placeholder: "请输入分类",
      }
    ]
  },
  {
    itemList: [
      {
        name: "content",
        label: "内容",
        labelAlign: "right",
        type: "quill",
        Component: ReactQuill,
        componentProps: {
          theme: 'snow',
          modules: {
            toolbar: [
              [
                {
                  header: [1, 2, false],
                },
              ],
              ['bold', 'italic', 'underline', 'strike', 'blockquote'],
              [
                {
                  list: 'ordered',
                },
                {
                  list: 'bullet',
                },
                {
                  indent: '-1',
                },
                {
                  indent: '+1',
                },
              ],
              ['image'],
            ],
          },
          formats: [
            'header',
            'bold',
            'italic',
            'underline',
            'strike',
            'blockquote',
            'list',
            'bullet',
            'indent',
            'link',
            'image',
          ],
        },
        rules: [
          {
            message: "内容是必填项",
            required: true
          }
        ],
        width: "md",
        placeholder: "请输入内容",
      }
    ]
  },
  {
    itemList: [
      {
        name: "picUrl",
        label: "图片",
        labelAlign: "right",
        type:"upload",
        componentProps:{
          listType: "picture-card",
          showUploadList: false,
          button: false
        },
        rules: [
          {
            // message: "图片是必填项",
            // required: true
          }
        ],
        width: "md",
        placeholder: "请上传图片",
      }
    ]
  },
]
export default fields;
